package com.arobs.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

@Service("statisticsService")
public class StatisticsServiceImpl implements StatisticsService {
	private static Map<String, Integer> statisticsMap = new HashMap<String, Integer>();
	
	public void addNewValue(String activity, Integer value) {
		Integer oldValue = statisticsMap.get(activity);
		
		statisticsMap.put(activity, oldValue == null ? value : oldValue + value);
		
		System.out.println("Added new value " + value + " for activity " + activity + ". New statistics map : " + statisticsMap);
	}

	public Map<String, Integer> getGlobalStatistics() {
		return statisticsMap;
	}

}
